#pragma once

#include <Windows.h> // Include the Win32 API
#include <tchar.h> // Include support for UNICODE
#include <sstream> // Include wostringstream support
#include <ctime>
using namespace std;


//SGD Wrappers
class CSGD_Direct3D;
class CSGD_DirectInput;
class CSGD_TextureManager;
class CSGD_XAudio2;

class ObjectManager;


#include "GameState.h"

class Game
{
public:	
	//////////////////////////////////////////////////////////
	// Singleton accessors:
	static Game* GetInstance( void );
	static void DeleteInstance( void );
	// Window Handle & window instance:
	HWND hWnd;
	HINSTANCE hInstance;
	
	
	//////////////////////////////////////////////////////////
	// Window Accessors:
	int GetScreenWidth ( void ) const	{	return ScreenWidth;		}
	int GetScreenHeight( void ) const	{	return ScreenHeight;	}
	bool GetIsWindowed ( void ) const	{	return IsWindowed;		}
	void SetIsWindowed ( bool isWindow );

	void ChangeState( GameState* pState );

private:
	//////////////////////////////////////////////////////////
	// SGD Wrappers
	CSGD_Direct3D*			pD3D;
	CSGD_DirectInput*		pDI;
	CSGD_TextureManager*	pTM;
	CSGD_XAudio2*			pXA;

	//////////////////////////////////////////////////////////
	// Data Managers 
	ObjectManager* objManager;

	//////////////////////////////////////////////////////////
	// Window Attributes
	int						ScreenWidth;
	int						ScreenHeight;
	bool					IsWindowed;

	int logoImageID;
	int menuMusicID;

	//////////////////////////////////////////////////////////
	// Current Game State
	GameState*				pCurrState;
	//////////////////////////////////////////////////////////
	//Whether the game has focus or not
	bool					hasFocus;

	//////////////////////////////////////////////////////////
	// Static pointer to the singleton object
	static Game* pInstance;

	// Private constructor / destructor to prevent multiple objects
	Game( void );						// default ctor
	~Game( void );						// dtor
	Game( const Game& );				// copy ctor
	Game& operator= ( const Game& );	// assignment op

	//////////////////////////////////////////////////////////
	// Helper Methods
	bool Input( void );
	void Update( );
	void Render( void );
	
public:
	/////////////////////////////////////////////////////////
	//WinMain Variables/Functions:
	BOOL bRunning;		// Is the game running?
	HANDLE hGameThread; // Handle to the GameMain thread.

	void Begin(HWND hWnd, HINSTANCE hInstance, int nWidth, int nHeight, bool bIsWindowed );
	void Main();
	void End(void);

	void Shutdown();

	void PauseGame();
	void UnpauseGame();

	void SetWindowed(bool windowed);


//PUT THIS IN TIME CLASS
#pragma region Variables used to calculate frames per second:
	DWORD dwFrames;
	DWORD dwCurrentTime;
	DWORD dwLastUpdateTime;
	DWORD dwElapsedTime;
	std::wstring szFPS;
#pragma endregion
};


